package com.wsd.common.entity;


import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;

public class UserTokenEntity {

    @JsonAlias("session_key")
    @NotNull
    private String sessionKey;

    @JsonAlias("openid")
    @NotNull
    private String openId;

    @JsonAlias("unionid")
    private String unionId;

    public static UserTokenEntity build(String response) {
        try {
            return new ObjectMapper().readValue(response, UserTokenEntity.class);
        } catch (Exception e) {
            return null;
        }
    }

    public String getSessionKey() {
        return sessionKey;
    }

    public void setSessionKey(String sessionKey) {
        this.sessionKey = sessionKey;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getUnionId() {
        return unionId;
    }

    public void setUnionId(String unionId) {
        this.unionId = unionId;
    }
}
